package Workflow;

import java.util.concurrent.BlockingQueue;

import javax.swing.SwingWorker;

import Model.Candidate;
import Model.Report;

public class MessageSendTask extends SwingWorker<BlockingQueue<Candidate>, Candidate> {
	BlockingQueue<Candidate> inQueue;
	BlockingQueue<Candidate> outQueue;
	private Candidate candidate;
	
	public MessageSendTask (BlockingQueue<Candidate> inQ, BlockingQueue<Candidate> outQ){
		inQueue = inQ;
		outQueue = outQ;
		/*
		 * TODO SWING ablak
		 */
	}
	

	public void addCandidate(Candidate c){
		try {
			outQueue.put(c);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void getCandidate(){
		try {
			candidate = inQueue.take();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	private void send(){
		getCandidate();
		candidate.messageSent = true;
		addCandidate(candidate);
	}
	

	@Override
	protected BlockingQueue<Candidate> doInBackground() throws Exception {
		send();
		System.out.println("MessageSend()" + outQueue.size());
		return null;
	}

}
